/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DAO;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 *
 * @author victor
 */
public class Configurator{
    protected Integer i;
    static String host = "localhost";
    static String arq = "configurator.bat";
    protected ObjectInputStream in;
    protected ObjectOutputStream out;

    public static String getHost() {
        return host;
    }

    public static void setHost(String host) {
        Configurator.host = host;
    }

    public static String getArq() {
        return arq;
    }

    public static void setArq(String arq) {
        Configurator.arq = arq;
    }

    public ObjectInputStream getIn() {
        return in;
    }

    public void setIn(ObjectInputStream in) {
        this.in = in;
    }

    public ObjectOutputStream getOut() {
        return out;
    }

    public void setOut(ObjectOutputStream out) {
        this.out = out;
    }

    public Integer getI() {
        return i;
    }

    public void setI(Integer i) {
        this.i = i;
    }

     public Configurator() {
            
     }
     public void gravarChave(Integer i){
         this.setI(i);
         try {
            this.out = new ObjectOutputStream(new FileOutputStream(arq));
            out.writeObject(i);
            out.flush();
            out.close();
             System.out.println("Chave Redefinida com sucesso");
         } catch (IOException ex) {
            ex.printStackTrace();
         }
     }
     public void lerChave(){
        try {
            this.in = new ObjectInputStream(new FileInputStream(arq));
            i = (Integer) in.readObject();
            in.close();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }catch (IOException ex){
            ex.printStackTrace();
        }
        catch(ClassNotFoundException ex){
            ex.printStackTrace();
        }
     }
}
